#include<bits/stdc++.h>
using namespace std;
int quickpow(int a, int b){
    if(b == 1)
    {
        return a;
    }
    else
    {
        int c = quickpow(a, b / 2);
        if(b % 2 == 0)
        {
            int m=c*c%1000;
            return m;
        }
        else
        {
            int n=c*c*a%1000;
            return n;
        }
    }
}

int main(){
    int a=0,b=0;
    cin>>a>>b;
    int m=quickpow(a,b);
    int c[3];
    for(int i=2;i>=0;i--)
    {
        c[i]=m%10;
        m /=10;
    }
    int sum=0;
    sum +=c[0]*10*10+c[1]*10+c[2];
    cout<<sum;
    return 0;
}